<template>
  <div class="my_card">
    <slot name="title">
      <div class="my_card_title">
        <p v-if="title">{{ title }}</p>
        <slot name="leftButtonGroup">
          <el-button v-if="back" type="primary" link @click="backFunction==undefined?router.back():backFunction()">
            返回
          </el-button>
        </slot>
      </div>
    </slot>
    <el-scrollbar v-if="!no_scrollbar" class="my_card_content">
      <slot></slot>
    </el-scrollbar>
    <slot v-else></slot>
  </div>
</template>

<script lang="ts" setup>
import router from "../router/router";

const props = defineProps({
  title: String,
  back: Boolean,
  backFunction: Function,
  no_scrollbar: Boolean
})
</script>

<style scoped lang="scss">
.fullHeight {
  height: 100%;
}

.my_card {
  background-color: white;
  display: flex;
  flex-direction: column;
  border: 1px #eee solid;
  padding: 10px;
  box-sizing: border-box;
  border-radius: 4px;
  overflow: hidden;

  .my_card_title {
    display: flex;
    flex-direction: row;
    box-sizing: border-box;
    border-bottom: 1px #ccc solid;
    justify-content: space-between;
    padding: 0 10px;

    p {
      font-weight: bold;
      font-size: 1.1em;
    }
  }

  .my_card_content {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
  }
}
</style>